/**
 * 
 */
package valverde.nacho.stripes;

import java.util.List;

import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.RedirectResolution;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.SimpleMessage;
import valverde.nacho.domain.Contact;

/**
 * @author ignacio.canon@entelgy.com
 */
public class ContactListActionBean extends MyActionBeanBase {

    @DefaultHandler
    public Resolution list() {
	return new ForwardResolution(LIST);
    }

    /**
     * @return
     */
    public List<Contact> getContacts() {
	return getContactDao().read();
    }

    public Resolution view() {
	return new ForwardResolution(VIEW);
    }

    public Resolution delete() {
	Contact deleted = getContactDao().read(getContactId());
	getContactDao().delete(getContactId());
	getContext().getMessages().add(new SimpleMessage("Deleted {0}.", deleted));
	return new RedirectResolution(getClass());
    }

}